#include "stdio.h"
#include "unistd.h"
#include "sys/types.h"
#include "sys/stat.h"
#include "fcntl.h"
#include "stdlib.h"
#include "string.h"


int main(int argc, char *argv[])
{
    int fd;
    int ret;
    char *filename;
    unsigned char databuf[1];

    if(argc != 3)
    {
        printf("error args!\n");
        return -1;
    }
    filename = argv[1];
    fd = open(argv[1], O_RDWR);
    if(fd < 0)
    {
        printf("file %s open failed!\n", argv[1]);
        return -1;
        
    }

    databuf[0] = atoi(argv[2]);
    ret = write(fd, databuf, sizeof(databuf));
    if(ret < 0)
    {
        printf("write databuf failed!\n");
        return -1;
    }
    close(fd);
    return 0;      
}